package com.boot.security.server.dao.user;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.user.TswUser;

@Mapper
public interface TswUserDao {

    @Select("select * from tsw_user t where t.id = #{id}")
    TswUser getById(Long id);

    @Delete("delete from tsw_user where id = #{id}")
    int delete(Long id);

    int update(TswUser tswUser);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tsw_user(user_nickname, user_wx_publicid, user_wx_openid, user_qq_openid, user_wb_openid, user_sex, user_phone, user_birth, user_idNumber, user_code_path, recommended_code, user_picurl, registration_time, registered_source, collect_number, update_information_time, lucky_draw, user_location, login_pwd, trade_password, state, user_note, user_remark, user_standby) values(#{userNickname}, #{userWxPublicid}, #{userWxOpenid}, #{userQqOpenid}, #{userWbOpenid}, #{userSex}, #{userPhone}, #{userBirth}, #{userIdNumber}, #{userCodePath}, #{recommendedCode}, #{userPicurl}, #{registrationTime}, #{registeredSource}, #{collectNumber}, #{updateInformationTime}, #{luckyDraw}, #{userLocation}, #{loginPwd}, #{tradePassword}, #{state}, #{userNote}, #{userRemark}, #{userStandby})")
    int save(TswUser tswUser);
    
    int count(@Param("params") Map<String, Object> params);

    List<TswUser> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
